package com.hbnu.zhouxunfa;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
import java.util.UUID;

/**
 * @Author: 周训发
 * @CreateTime: 2025-10-29
 * @Description: 客户端
 * @Version: 1.0
 */

public class Client {
    public static void main(String[] args) {

        try {
            Socket socket = new Socket("127.0.0.1",8080);
            OutputStream os = socket.getOutputStream();
            String str = "hello,世界！";
            os.write(str.getBytes());
            socket.shutdownOutput();

            InputStream is = socket.getInputStream();
            int len;
            while ((len=is.read())!=-1){
                System.out.println((char) len);
            }
            os.close();
            socket.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
